-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support BLACK_SCREEN, add format inference, and add new demo #124
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8ad48f6
Support BLACK_SCREEN
Devon7925 ce6e427
Improved image binding creation
Devon7925 62ddfdf
Improve string hash handling
Devon7925 4bf0b6a
Fix compilation only shaders failing on binding generation
Devon7925 4f449f1
Improve texture format handling
Devon7925 42ac1a5
Make sizeFromFormat use switch
Devon7925 9628e09
Add missing return for size 8 textures
Devon7925 d50b14b
improve format inference using reflection JSON
Devon7925 7617650
Merge branch 'main' into black-screen
Devon7925 fda7f1a
Make formats apply to URL textures
Devon7925 fa54b4d
remove temporary try catch
Devon7925 e92db87
Add check to make sure data is not outdated when rendering
Devon7925 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import playground; | ||
|
||
const static int MAX_BRUSH_SIZE = 16; | ||
|
||
[playground::BLACK_SCREEN(1.0, 1.0)] | ||
RWTexture2D<float> tex_red; | ||
[playground::BLACK_SCREEN(1.0, 1.0)] | ||
RWTexture2D<float> tex_green; | ||
[playground::BLACK_SCREEN(1.0, 1.0)] | ||
RWTexture2D<float> tex_blue; | ||
|
||
[playground::SLIDER(10.0, 4.0, 16.0)] | ||
uniform float brush_size; | ||
[playground::COLOR_PICK(1.0, 0.0, 1.0)] | ||
uniform float3 color; | ||
|
||
[playground::MOUSE_POSITION] | ||
uniform float4 mousePosition; | ||
|
||
[shader("compute")] | ||
[numthreads(8, 8, 1)] | ||
[playground::CALL(MAX_BRUSH_SIZE, MAX_BRUSH_SIZE, 1)] | ||
void draw(uint2 dispatchThreadId: SV_DispatchThreadID) | ||
{ | ||
if (mousePosition.z >= 0) | ||
return; | ||
|
||
let offset = float2(dispatchThreadId.xy) - float(MAX_BRUSH_SIZE) / 2; | ||
if (length(offset) > brush_size / 2) | ||
return; | ||
|
||
var mouse_pos = uint2(mousePosition.xy + offset); | ||
tex_red[mouse_pos] = color.r; | ||
tex_green[mouse_pos] = color.g; | ||
tex_blue[mouse_pos] = color.b; | ||
} | ||
|
||
float4 imageMain(uint2 dispatchThreadID, int2 screenSize) | ||
{ | ||
uint imageW; | ||
uint imageH; | ||
tex_red.GetDimensions(imageW, imageH); | ||
|
||
uint2 scaled = (uint2)floor(float2(dispatchThreadID.xy)); | ||
uint2 flipped = uint2(scaled.x, imageH - scaled.y); | ||
|
||
float4 imageColor = float4(tex_red[flipped], tex_green[flipped], tex_blue[flipped], 1.0); | ||
return imageColor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering that if we can extend this attribute to like "COLOR_SCREEN" attribute that we can accept a single color to clear the texture?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it but decided against it because:
It might make sense to have a set of
DEFAULT_VALUE_
attributes that can also apply to buffers though...In which case the attributes should be renamed:
ZEROS
->BUFFER
BLACK
->TEXTURE
BLACK_SCREEN
->SCREEN_TEXTURE